from microbit import *

# Start calibrating if A pressed
if button_a.is_pressed():
    compass.calibrate()

# calc needle and show
while True:
    sleep(100)
    needle = ((15 - compass.heading()) // 30) % 12
    display.show(Image.ALL_CLOCKS[needle])